import random

def mazeBuild(length, width, percent): ##随机生成构建地图，按percent比例生成障碍物
    obstacle = []
    obstacle_num = int(length * width * percent)
    for i in range(obstacle_num + 2):
        if i < obstacle_num:
            x = random.randint(0, length - 1)
            y = random.randint(0, width - 1)
            location = (x,y)
            obstacle.append(location)
        elif i == obstacle_num:
            x = random.randint(1, length - 3)
            y = random.randint(1, width - 3)
            startPPoint = (x,y)
        elif i == obstacle_num + 1:
            x = random.randint(1, length - 3)
            y = random.randint(1, width - 3)
            endPPoint = (x,y)

    for i in range(length):
        location = (i,0)
        obstacle.append(location)
        llocation = (i,width - 2)
        obstacle.append(llocation)

    for i in range(width):
        location = (0,i)
        obstacle.append(location)
        llocation = (length - 2,i)
        obstacle.append(llocation)

    return obstacle, startPPoint, endPPoint